package JmmAndMultiThread.MultiThreads;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class MultiThreadExecutors {
    public static void main(String[] args) {
        Thread threadA = new Thread(() -> {
            System.out.println("Thread = [" + "A" + "]");
        });
        Thread threadB = new Thread(() -> {
            System.out.println("Thread = [" + "B" + "]");
        });
        Thread threadC = new Thread(() -> {
            System.out.println("Thread = [" + "C" + "]");
        });
        Thread threadD = new Thread(() -> {
            System.out.println("Thread = [" + "D" + "]");
        });
        //ExecutorService实现按序输出
        ExecutorService executorService= Executors.newSingleThreadExecutor();
        executorService.submit(threadA);
        executorService.submit(threadB);
        executorService.submit(threadC);
        executorService.submit(threadD);
        executorService.shutdown();

    }
}
